Getting the Displayed Value for a Spin List Control

Description

When you define the choices with which to populate a Spin List control, you can specify a 'display value' and a 'stored value' for each value. When you read the current value in the control (using the {dialog.object}.getValue() method, or the .value property on the Spin List object itself), you well be reading the stored value. In this tip we show you how to get the current display value.

Discussion

Assume that the Spin List control id is 'spin1'

//get a pointer to the Spin List control
var s = {dialog.object}.getControl('spin1');

var v = s.value; //get the current value
var _d = s._data; //get the array of data in the Spin List

//find the index in the array where the array's 'value' property
//matches the current value in the Spin List
var indx = {dialog.object}._findArrayProp(_d,'value',v);
var html = _d[indx].html;
alert(html);